package cn.com.surker.workcon.service.xugong;

import cn.com.surker.base.system.entity.SysLine;
import cn.com.surker.util.DateUtil;

import java.util.Date;

/**
 * 徐工的工具类
 *
 * @author luotao
 * @date 2025/5/23
 */
public class XgUtil {

	//	中间库表明前缀
	private final static String DOCKING_PREFIX = "ERP30";
	//	工控表名前缀
	private final static String LIBRARY_PREFIX = "Library";

	/**
	 * 获取中间库表名
	 *
	 * @param line
	 * @param table
	 * @return
	 */
	protected static String getDockTableName(SysLine line, String table) {
		String res = DOCKING_PREFIX + "_" + line.getControlLineId() + ".dbo." + table;
		return res;
	}

	/**
	 * 获取本地库表名
	 *
	 * @param line
	 * @param prefix
	 * @param suffix
	 * @return
	 */
	protected static String getLibraryTableName(SysLine line, String prefix, String suffix) {
		String res = DOCKING_PREFIX + "_" + line.getControlLineId() + ".dbo." + prefix + getTableMonth() + suffix;
		return res;
	}

	/**
	 * 获取表名中的月份
	 *
	 * @return
	 */
	protected static String getTableMonth() {
		Date nowDate = new Date();
		String yyyymm = DateUtil.convertString(nowDate, "YYYYMM");
		return yyyymm;
	}
}
